package com.example.demo.mapper;

import com.example.demo.pojo.Music;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface MusicMapper {
    @Select("select * from music_ ")
    List<Music> findAll();

    @Select("select count(*) from music_ ")
    int getCount();

    @Select("select * from music_ limit #{start}, #{limit}")
    List<Music> findByPage(int start, int limit);

    @Insert("insert into music_ values ( null , #{name}, #{singer}, #{imgPath}, #{musicPath}, #{lyricPath} ) ")
    int add(Music music);

    @Delete("delete from music_ where id = #{id} ")
    void delete(int id);

    @Select("select * from music_ where id = #{id} ")
    Music get(int id);
}
